﻿using Newtonsoft.Json.Linq;
using ServerCommon.Log;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ServerCommon.Config
{
    public class ConfigManager
    {
        public static readonly ConfigManager Instance = new Lazy<ConfigManager>(() => new ConfigManager(), true).Value;
        private static LogHelper log = LogHelper.GetLogger(typeof(ConfigManager));

        public JToken NetConfig => _netConfig;
        private JToken _netConfig;

        public JToken ServerConfig => _serverConfig;
        private JToken _serverConfig;

        public void InitNetConfig(string file)
        {
            string jsonStr = File.ReadAllText(file, System.Text.Encoding.UTF8);
            JObject jobj = JObject.Parse(jsonStr);
            _netConfig = jobj as JToken;
        }

        public void InitServerConfig(string file)
        {
            string jsonStr = File.ReadAllText(file, System.Text.Encoding.UTF8);
            JObject jobj = JObject.Parse(jsonStr);
            _serverConfig = jobj as JToken;
        }
    }
}
